<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../../taglibs.jsp" %>
<script type="text/javascript">
	$(function() {
		$("#query").click(function() {
			$("[name='pageNum']").val(1);
			$("form:first").submit();
		});
		
		
		var orderState = $("#orderState").val();
		var orderType = $("#orderType").val();
		if(orderState == "2" && orderType == "2"){
			$("#tab1").addClass("here");
			$("#tab1 a").addClass("taba");
		}else if(orderState == "4" && orderType == "2"){
			$("#tab2").addClass("here");
			$("#tab2 a").addClass("taba");
		}
	});
	
	
	function popOrderDetail(orderId){
		var diag = new Dialog();
		diag.Width = 850;
		diag.Height = 400;
		diag.Title = "运输单任务指派";
		
		diag.URL = "${path}/orderTran_tran_view?orderModel.orderId="+orderId+"&depId=8";
		diag.OKEvent = function(){
			//获得子页面的文档内容对象
			 var doc=diag.innerFrame.contentWindow;
			//alert(doc.age)
			var result = doc.assginEmp(orderId);
			if(result == "yes"){
				diag.close();
				window.location.href="${path }/orderTran_tran_list?erpQuery.orderState=2&erpQuery.orderTypeStr=2";
			}
		};
		
		diag.show();
		/* diag.addButton("pass","通过",function(){
			
		}); */
		
		
	}
</script>
<style>
	ul li{
		list-style-type: none;
		border: 1px solid #539200;
		float: left;
		margin-left: 2px;
		padding: 5px;
		width: 70px;
		border-bottom: 1px solid #F3FFE3;
		text-align: center;
	}
	
	.here{
		background-color: #539200;
		color: white;
		border-bottom: 1px solid #539200;
		font-size: 14px;
		font-weight: bold;
	}
	li a{
		text-decoration: none; color: black;
	}
	.taba{
		color: white;
		font-size: 14px;
		font-weight: bold;
	
	}
</style>
<div class="content-right">
	<div class="content-r-pic_w">
		<div style="margin:8px auto auto 12px;margin-top:6px">
			<span class="page_title">进货订单管理</span>
		</div>
	</div>
	<div class="content-text">
		<form action="${path }/orderModel_buy_list" method="post">
			<!-- 定义一个订单状态的隐藏域的回显，目的是做tab的选中状态 -->
			<input type="hidden" id="orderState" name="erpQuery.orderState" value="<s:property value="erpQuery.orderState"/>"> 
			<input type="hidden" id="orderType" name="erpQuery.orderTypeStr" value="<s:property value="erpQuery.orderTypeStr"/>"> 
			<div class="square-o-top">
				<table width="100%" border="0" cellpadding="0" cellspacing="0"
					style="font-size:14px; font-weight:bold; font-family:"黑体";">
					<tr>
						<td height="30">订单号</td>
						<td> 
							
							<s:textfield name="erpQuery.orderNum" size="14" ></s:textfield>
						</td>
						<td>下单人:</td>
						<td><s:textfield name="erpQuery.orderCreaterName" size="14" ></s:textfield></td>
						<td>总量:</td>
						<td><s:textfield name="erpQuery.totalNumMin" size="14" ></s:textfield></td>
						<td>到 </td>
						<td>&nbsp;&nbsp;<s:textfield name="erpQuery.totalNumMax" size="14" ></s:textfield></td>
						<td><a id="query"> 
							<img src="${path}/images/can_b_01.gif" border="0" /> </a>
						</td>
					</tr>
					<tr>
						<td>下单时间:</td>
						<td>
							<s:textfield name="erpQuery.createTimeStart" size="14" onfocus="c.showMoreDay=false;c.show(this);" readonly="true"></s:textfield>
						</td>
						<td>到</td>
						<td>
							<s:textfield name="erpQuery.createTimeEnd" size="14" onfocus="c.showMoreDay=false;c.show(this);" readonly="true"></s:textfield>
						</td>
						<td>总额:</td>
						<td><s:textfield name="erpQuery.totalPriceMin" size="14" ></s:textfield></td>
						<td>到</td>
						<td>&nbsp;&nbsp;<s:textfield name="erpQuery.totalPriceMax" size="14" ></s:textfield></td>
						<td>
							<a href="#" onclick="popAddBuyOrder()">
								<img src="${path}/images/can_b_02.gif" border="0" /> 
							</a>
						</td>
					</tr>
				</table>
			</div>
			<!--"square-o-top"end-->
			<div>
				<ul>
					<li id="tab1"><a href="${path }/orderTran_tran_list?erpQuery.orderState=2&erpQuery.orderTypeStr=2" >待采购</a></li>
					<li id="tab2"><a href="${path }/orderTran_tran_list?erpQuery.orderState=4&erpQuery.orderTypeStr=2">采购中</a></li>
					
				</ul>
				
			</div>
			
			
			
				<div class="square-order" style="border-top: 2px solid #539200;padding-top: 2px;" >
				
					<table width="100%" border="1" cellpadding="0" cellspacing="0">
						<%-- <tr align="center"
							style="background:url(${path}/images/table_bg.gif) repeat-x;">
							<td width="25%" height="30">订单号</td>
							<td width="9%">供应商</td>
							<td width="10%">制单人</td>
							<td width="20%">制单时间</td>
							<td width="10%">订单商品总量</td>
							<td width="12%">订单总金额</td>
							
							<td width="9%">订单状态</td>
							<td width="5%">操作</td>
						</tr> --%>
						
						<tr align="center"
							style="background:url(${path}/images/table_bg.gif) repeat-x;">
							<td width="10%" height="30">订单类别</td>
							<td width="13%">下单时间</td>
							<td width="13%">制单人</td>
							<td width="13%">审核时间</td>
							<td width="13%">审核人</td>
							<td width="15%">供应商</td>
							<td width="13%">发货方式</td>
							<td width="10%">跟单人</td>
						</tr>
						
						<s:iterator value="#page.list" var="order">
							<s:set var="orderType" value="#order.orderType"></s:set>
							<s:set var="needs" value="#order.supplier.needs"></s:set>
							<tr align="center" bgcolor="#FFFFFF">
								<td width="13%" height="30"><e:getTxt type="orderType" value="${orderType }"></e:getTxt></td>
								<td><s:property value="#order.createTime"/></td>
								<td><s:property value="#order.orderCreater.name"/></td>
								<td><s:property value="#order.checkTime"/></td>
								<td><s:property value="#order.orderChecker.name"/></td>
								<td align="right"><s:property value="#order.supplier.name"/></td>
								
								<td><e:getTxt type="needs" value="${needs }"></e:getTxt></td>
								<td>
									
									<s:if test="#order.orderState == 2">
									
										<input type="button" value="任务指派" onclick="popOrderDetail(<s:property value="#order.orderId"/>)">
										
									</s:if>
									<s:else>
										<s:property value="#order.orderCompleter.name"/>
									</s:else>
								</td>
							</tr>
						</s:iterator>
						
					</table>
					<%@include file="../../tools/paging.jsp" %>
				</div>
		</form>
	</div>
	<div class="content-bbg"></div>
</div>
